#ifndef __WORKERTHREAD_H__
#define __WORKERTHREAD_H__

#include "thread.h"
#include "server.h"
#include "RecycleQueue.h"
#include "connection.h"
#include "ioManager.h"
#include "log.h"

extern confMgr *conf;
/**
 * @brief 工作线程的上下文;
 */
struct workerThread_ctx 
{
	struct pthread_ctx pth;
	int sockfd; //
	ioModel *io;
	int ioType;
	ConnectionSet conn; //
	RecycleQueue< struct connection *> queue;
	bool bStopFlag;
	int logfd; //和日志线程交互的套接字;
	char *logbuf; //日志信息缓冲区;
	int bufSize; //缓冲区的大小;
};




//处理线程类;
class workerThread:public thread{
public:
	workerThread();
	~workerThread();
	int init(void *arg);
	int handleEvent();
	static int workerThreadHandle(int count, struct workerThread_ctx *ctx);
	static void * workerThreadRun(void *arg);
	MemPool & getMemOpt() { return mem; }
private:
	std::vector<struct workerThread_ctx *> workqueue;
	size_t uworkThreadCount;
	struct server_conf_st serconf;
	MemPool mem;
};




#endif 
